/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-05-18
 * Time: 14:19
 */
public class Test1 {
    public static boolean isSuShu(int x){
        int flag = 0;
        if(x == 2){
            return true;
        }
        for(int i = 2;i < x; i++){
            if(x%i == 0){
               flag = 1;
            }
        }
        if(flag == 0){
            return true;
        }
        return false;
    }
    public static boolean isHuiWen(int x){
        String str1 = x + "";
        String str2 = "";
        for(int i = str1.length()-1; i>=0;i--){
            str2 =str2 +str1.charAt(i);
        }
        if(str1.equals(str2)){
            return true;
        }
        return false;

    }

    public static void main(String[] args) {
        int n = 0;
        int x = 2;
        while(true){
            if(isHuiWen(x)){
                if(isSuShu(x)){
                    n++;
                    System.out.print(x+" ");
                    if(n%10 == 0){
                        System.out.println();
                    }
                }
            }
            if(n == 100){
                break;
            }
            x++;
        }

    }
}
